//
//  BuyItemCollectionView.swift
//  HappyToSee
//
//  Created by Wade on 2024/7/5.
//

import Foundation
import UIKit
class KEDetailCollectionCell :UICollectionViewCell{
    var bgImageView:UIImageView?
    var titleLabel:UILabel?
    var priceLabel:UILabel?
    var tipLabel:UILabel?
    private var _cellSelect:Bool = false
    
    
    var setCellSelect:Bool  {
        get{
            return _cellSelect
        }
        
        set{
            _cellSelect = newValue
            if _cellSelect == false{
                self.bgImageView?.image = UIImage(named: "bg_buy_nor")
                let color = UIColor.qmui_color(withHexString: "#E2B86B")
                self.titleLabel?.textColor = color
                self.priceLabel?.textColor = color
                self.tipLabel?.textColor = color
                
            }else{
                self.bgImageView?.image = UIImage(named: "bg_buy_sel")
                let color = UIColor.qmui_color(withHexString: "#46310D")
                self.titleLabel?.textColor = color
                self.priceLabel?.textColor = color
                self.tipLabel?.textColor = color
            }
        }
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.setupSubViews()
    }
    
    func setupSubViews(){
        self.backgroundColor = .clear;
        let bgImageView = UIImageView()
        bgImageView.contentMode = .scaleAspectFill
        
        self.addSubview(bgImageView)
        bgImageView.image = UIImage(named: "bg_buy_nor")
        bgImageView.snp.makeConstraints { make in
            make.edges.equalTo(self)
        }
        self.bgImageView = bgImageView
      
        
        let label1 = UILabel()
        label1.textColor = UIColor.qmui_color(withHexString: "#E2B86B")
        label1.textAlignment = .center
        label1.font = .systemFont(ofSize: 30)
        let attStr = NSMutableAttributedString(string: "￥98")
        attStr.addAttribute(.font, value: UIFont.boldSystemFont(ofSize: 13), range: NSRange(location: 0, length: 1))
        attStr.addAttribute(.font, value: UIFont.systemFont(ofSize: 30), range: NSRange(location: 1, length: attStr.length - 1))
        label1.attributedText = attStr
        self.addSubview(label1)
        label1.snp.makeConstraints { make in
            make.left.right.equalTo(self)
            make.centerY.equalTo(self)
            make.height.equalTo(40)
        }
        self.priceLabel = label1
   
        
    }
    
    override func layoutSubviews() {
        
    }
}
